package com.twp.auth.component;

import com.twp.auth.config.auth.AuthConfig;
import com.twp.common.utils.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class Md5Component {
    @Autowired
    AuthConfig authConfig;

    public String encode(String rawPassword) {
        return MD5Util.encode(authConfig.getSalt(),rawPassword);
    }

    public boolean matches(String rawPassword, String encodedPassword) {
        return encodedPassword.equals(MD5Util.encode(authConfig.getSalt(),rawPassword));
    }
}
